package com.atguigu.qqzone.controller;

import com.atguigu.qqzone.pojo.HostReply;
import com.atguigu.qqzone.pojo.Reply;
import com.atguigu.qqzone.pojo.Topic;
import com.atguigu.qqzone.pojo.UserBasic;
import com.atguigu.qqzone.service.impl.HostReplyServiceImpl;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * @ClassName: HostReplyController
 * @Description:
 * @Author: wty
 * @Date: 2022/12/11
 */

public class HostReplyController {
    private HostReplyServiceImpl hostReplyServiceImpl;

    public String addHostReply(String content, Integer replyId, HttpSession session) {
        UserBasic author = (UserBasic) session.getAttribute("userBasic");
        Reply reply = new Reply(replyId);

        HostReply hostReply = new HostReply(content, new Date(), author, reply);

        hostReplyServiceImpl.addHostReply(hostReply);

        // 重定向返回日志详情
        Topic topic = (Topic) session.getAttribute("topic");
        return "redirect:topic.do?operate=topicDetail&id=" + topic.getId();

    }
}
